package com.sc.nft.dao;

import com.sc.nft.entity.CollectionChainInitDetailsLog;
import com.sc.nft.entity.vo.TmpCollectionVO;
import com.sc.nft.enums.CollectionChainDealStatusEnum;
import com.sc.nft.enums.UserChainLogStatusEnum;

import java.util.List;

import static com.sc.nft.constant.TableNameConstants.COLLECTION_CHAIN_INIT_DETAILS_LOG;

/**
 * 由于内部使用分区表机制，避免直接继承 IService / ServiceImpl 来提供默认实现，可能会错误路由到其它库
 *
 * @author zlikun
 * @since 2024/06/20
 */
public interface CollectionChainInitDetailsLogDao {

    String TABLE = COLLECTION_CHAIN_INIT_DETAILS_LOG;

    void insertBatch(List<CollectionChainInitDetailsLog> list);

    List<TmpCollectionVO> getTmpData();

    List<CollectionChainInitDetailsLog> getListByStatusAndDealStatusAndCollectionId(Long collectionId, UserChainLogStatusEnum userChainLogStatusEnum, CollectionChainDealStatusEnum collectionChainDealStatusEnum);

    List<Long> getWithTransferQueue(Long collectionId);

    Long getOneTypeIds(UserChainLogStatusEnum status, CollectionChainDealStatusEnum dealStatus);

    Integer getCountByStatusAndChainStatusAndCollectionId(UserChainLogStatusEnum status, CollectionChainDealStatusEnum dealStatus, Long collectionId);

    Boolean updateContractAddressAndTransactionHashAndStatusAndDealStatusByIds(String contractAddress, String transactionHash, UserChainLogStatusEnum status, CollectionChainDealStatusEnum dealStatus, List<Long> ids);

    Boolean updateDealStatusByIds(CollectionChainDealStatusEnum dealStatus, List<Long> ids);

    CollectionChainInitDetailsLog getOneByTransactionHash(String transactionHash);

    Boolean updateTokenIdAndNumberingById(Long id, Integer tokenId);

    Boolean updateContractAddressAndTransactionHashAndStatusAndDealStatusById(String contractAddress,
                                                                              String transactionHash,
                                                                              UserChainLogStatusEnum status,
                                                                              CollectionChainDealStatusEnum dealStatus,
                                                                              Long id);

    CollectionChainInitDetailsLog getOneByCollectionIdAndUuid(Long collectionId, String collectionUuid);

    List<CollectionChainInitDetailsLog> getListByCollectionId(Long collectionId);

    List<CollectionChainInitDetailsLog> getPageListByCollectionIdAndPage(Long collectionId, int pageNo, int pageSize);

    List<CollectionChainInitDetailsLog> getListByTransactionHash(String transactionHash);

    CollectionChainInitDetailsLog getOneByTokenIdAndCollectionId(Integer numbering, Long collectionId);

    Boolean updateDealStatusById(Long id, CollectionChainDealStatusEnum dealStatus);

    List<CollectionChainInitDetailsLog> metaChainInitListAndCollectionIdAndLimit(Long collectionId, UserChainLogStatusEnum status, CollectionChainDealStatusEnum dealStatus, int size);

    boolean updateDealStatusAndTransactionHashByCollectionIdAndNumbering(Long collectionId, String transactionHash, Integer tokenId);

    boolean updateDealStatusAndTransactionHashByCollectionIdAndNumbering(Long collectionId, String transactionHash, Integer tokenId, CollectionChainDealStatusEnum dealStatus);

    CollectionChainInitDetailsLog getOneByCollectionIdAnTokenId(Long collectionId, Integer numbering);

    CollectionChainInitDetailsLog getOneByCollectionIdAnTokenIdAndStatsAndDealStatus(Long collectionId, Integer tokenId, UserChainLogStatusEnum status);

    Boolean getOneByCollectionIdsAnTokenIdAndStatsAndDealStatus(Long collectionId, List<Integer> tokenIds, UserChainLogStatusEnum status);

    void updateDealStatusByCollectionIdAndTokenId(Long collectionId, Integer tokenId, CollectionChainDealStatusEnum dealStatus);

    CollectionChainInitDetailsLog getById(Long id);

    boolean updateById(CollectionChainInitDetailsLog model);


    /**
     * 获取排除list后随机获取指定数量的数据
     * @param collectionId
     * @param list
     * @param limit
     * @return
     */
    List<CollectionChainInitDetailsLog> getExcludeListByCollectionId(Long collectionId, List<Long> list, Integer limit);

}
